export default{
	
	methods:{
		//价格万位
		changePrice( value ){
			const newValue = ['', '', ''];
			let fr = 1000;
			let num = 3;
			let text1 = '';
			let fm = 1;
			while (value / fr >= 1) {
			  fr *= 10
			  num += 1
			  // console.log('数字', value / fr, 'num:', num)
			}
			if (num <= 8) { // 万
			  text1 = parseInt(num - 4) / 3 > 1 ? '千万' : 'W'
			  // tslint:disable-next-line:no-shadowed-variable
			  fm = text1 === 'W' ? 10000 : 10000000
			  if (value % fm === 0) {
				newValue[0] = parseInt(value / fm) + ''
			  } else {
				newValue[0] = parseFloat(value / fm).toFixed(2) + ''
			  }
			  newValue[1] = text1
			}
			if (value < 1000) {
			  newValue[0] = value + ''
			  newValue[1] = ''
			}
			return newValue.join('');
		},
		//获取某块高度
		getHeight( params1 ,params2 ){
			
			let height = 0;
			let p1H = 0;
			let p2H = 0;
			
			if(  params1  ){
				//uniapp自带获取dom的api	params1 是传过来的值
				let p1View = uni.createSelectorQuery().select(params1);
				p1View.boundingClientRect(data=>{
					p1H = data.height;
				}).exec();
			}
			
			if(  params2  ){
				//uniapp自带获取dom的api	params2 是传过来的值
				let p2View = uni.createSelectorQuery().select(params2);
				p2View.boundingClientRect(data=>{
					p2H = data.height;
				}).exec();
			}
			
			//可视区域 - 内容块
			uni.getSystemInfo({
				success( res ){
					height = res.windowHeight - p1H - p2H;
				}
			})
			
			return height;
		}
	}
	
}